package com.adingxiong.cft.design.adapter;

/**
 * @ClassName MediaAdapter
 * @Description TODO
 * @Author xiongchao
 * @Date 2021/1/8 15:09
 **/
public class MediaAdapter implements MediaPlayer {

    AdvancedMediaPlayer advancedMediaPlayer;

    public MediaAdapter(String audiType){
        if("vlc".equalsIgnoreCase(audiType)){
            advancedMediaPlayer =  new VlcPlayer();
        } else if ("mp4".equalsIgnoreCase(audiType)){
            advancedMediaPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String audioType, String fileName) {
        if(audioType.equalsIgnoreCase("vlc")){
            advancedMediaPlayer.playVlc(fileName);
        } else if (audioType.equalsIgnoreCase("mp4")){
            advancedMediaPlayer.playMp4(fileName);
        }
    }
}
